package com.ecfront.dao.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.BannerDAO;
import com.ecfront.pojo.Banner;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class BannerDAOImpl extends HibernateDaoSupport implements BannerDAO {

	protected void initDao() {}

	public void save(Banner transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}


	public void delete(Banner persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}


	public Banner findById(java.lang.Integer id) {
		Banner instance = (Banner) getHibernateTemplate().get(
					"com.ecfront.pojo.Banner", id);
		return instance;
	}


	public List findByProperty(String propertyName, Object value) {
		String queryString = "from Banner as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findAll() {
		String queryString = "from Banner";
		return getHibernateTemplate().find(queryString);
	}

	public static BannerDAO getFromApplicationContext(ApplicationContext ctx) {
		return (BannerDAO) ctx.getBean("BannerDAO");
	}
}